package com.bkgy.controller.technology.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bkgy.controller.cal.entity.TPdiDataL3Cal1630;
import com.bkgy.controller.cal.entity.TPdiDataL3Cal2150;
import com.bkgy.controller.cal.service.ITPdiDataL3Cal1630Service;
import com.bkgy.controller.cal.service.ITPdiDataL3Cal2150Service;
import com.bkgy.controller.technology.entity.AnnealingBase;
import com.bkgy.controller.technology.entity.CalProcessDatas;
import com.bkgy.controller.technology.entity.TTechAnnealingParam;
import com.bkgy.controller.technology.entity.dto.RollInfo;
import com.bkgy.controller.technology.entity.dto.TechAnnealingCharRes;
import com.bkgy.controller.technology.entity.dto.TechChartDtoReq;
import com.bkgy.controller.technology.entity.dto.TechListDtoRes;
import com.bkgy.controller.technology.mapper.ICalProcessMapper;
import com.bkgy.controller.technology.service.ICalProcessService;
import com.bkgy.controller.technology.service.ITechAnnealingParamService;
import com.bkgy.modular.datacollect_bx.bean.JDataSavemong1630;
import com.bkgy.modular.datacollect_bx.bean.JDataSavemong2150;
import com.bkgy.modular.tpdodata_cal1630.mapper.TPdoDataCal1630Mapper;
import com.bkgy.modular.tpdodata_cal2150.mapper.TPdoDataCal2150Mapper;
import com.bkgy.sys.common.entity.ResultData;
import com.bkgy.util.DateUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.*;

@Service
@Slf4j
@RequiredArgsConstructor
public class CalProcessServiceImpl extends ServiceImpl<ICalProcessMapper, CalProcessDatas> implements ICalProcessService {
    private final ITechAnnealingParamService paramService;
    private final ITPdiDataL3Cal1630Service pdi1630Service;
    private final ITPdiDataL3Cal2150Service pdi2150Service;
    private final MongoTemplate mongoTemplate;
    private final TPdoDataCal1630Mapper cal1630Mapper;
    private final TPdoDataCal2150Mapper cal2150Mapper;

    @Override
    public ResultData<TechAnnealingCharRes> selectTechFit(TechChartDtoReq tc) {
        TechAnnealingCharRes obj = new TechAnnealingCharRes();
        obj.setExtIdArr(new ArrayList<>());
        obj.setCredateArr(new ArrayList<>());
        obj.setCalProcessSpeedArr(new ArrayList<>());
        obj.setCalSpmRaArr(new ArrayList<>());
        obj.setCalHeatStripTempArr(new ArrayList<>());
        obj.setCalScStripTempArr(new ArrayList<>());
        obj.setCalRcStripTempArr(new ArrayList<>());
        obj.setCalOas3StripTempArr(new ArrayList<>());
        obj.setCalSpmElongActArr(new ArrayList<>());
        obj.setCalAlkali1WashCondArr(new ArrayList<>());
        obj.setCalAlkali2WashCondArr(new ArrayList<>());
        obj.setCalAlkali1WashTempArr(new ArrayList<>());
        obj.setCalAlkali2WashTempArr(new ArrayList<>());
        obj.setCalElecCleanCondArr(new ArrayList<>());
        obj.setCalElecCleanTempArr(new ArrayList<>());
        obj.setCalHotWaterRinseTempArr(new ArrayList<>());
        obj.setCalRcZ12H2Arr(new ArrayList<>());
        obj.setCalHeatH2Arr(new ArrayList<>());
        obj.setCalHeatFurPressureArr(new ArrayList<>());
        obj.setCalQuenchTempArr(new ArrayList<>());
        obj.setCalQuenchCondArr(new ArrayList<>());

        LambdaQueryWrapper<CalProcessDatas> w = buildCalWrapper(tc);
        w.select(CalProcessDatas::getExtid,
                CalProcessDatas::getEndtime,
                CalProcessDatas::getCalProcessSpeedAvg,
                CalProcessDatas::getCalSpmRaAvg,
                CalProcessDatas::getCalHeatStripTempAvg,
                CalProcessDatas::getCalScStripTempAvg,
                CalProcessDatas::getCalRcStripTempAvg,
                CalProcessDatas::getCalOas3StripTempAvg,
                CalProcessDatas::getCalSpmElongActAvg,
                CalProcessDatas::getCalAlkali1WashCondAvg,
                CalProcessDatas::getCalAlkali2WashCondAvg,
                CalProcessDatas::getCalAlkali1WashTempAvg,
                CalProcessDatas::getCalAlkali2WashTempAvg,
                CalProcessDatas::getCalElecCleanCondAvg,
                CalProcessDatas::getCalElecCleanTempAvg,
                CalProcessDatas::getCalHotWaterRinseTempAvg,
                CalProcessDatas::getCalRcZ12H2,
                CalProcessDatas::getCalHeatH2Avg,
                CalProcessDatas::getCalHeatFurPressureAvg,
                CalProcessDatas::getCalQuenchTempAvg,
                CalProcessDatas::getCalQuenchCondAvg
        );

        List<CalProcessDatas> calList = list(w);
        for (CalProcessDatas cal : calList) {
            obj.getExtIdArr().add(cal.getExtid());
            obj.getCredateArr().add(cal.getEndtime());
            obj.getCalProcessSpeedArr().add(cal.getCalProcessSpeedAvg());
            obj.getCalSpmRaArr().add(cal.getCalSpmRaAvg());
            obj.getCalHeatStripTempArr().add(cal.getCalHeatStripTempAvg());
            obj.getCalScStripTempArr().add(cal.getCalScStripTempAvg());
            obj.getCalRcStripTempArr().add(cal.getCalRcStripTempAvg());
            obj.getCalOas3StripTempArr().add(cal.getCalOas3StripTempAvg());
            if (cal.getCalSpmElongActAvg() != null) {
                obj.getCalSpmElongActArr().add(cal.getCalSpmElongActAvg().multiply(BigDecimal.valueOf(100)));
            } else {
                obj.getCalSpmElongActArr().add(null);
            }
            obj.getCalAlkali1WashCondArr().add(cal.getCalAlkali1WashCondAvg());
            obj.getCalAlkali2WashCondArr().add(cal.getCalAlkali2WashCondAvg());
            obj.getCalAlkali1WashTempArr().add(cal.getCalAlkali1WashTempAvg());
            obj.getCalAlkali2WashTempArr().add(cal.getCalAlkali2WashTempAvg());
            obj.getCalElecCleanCondArr().add(cal.getCalElecCleanCondAvg());
            obj.getCalElecCleanTempArr().add(cal.getCalElecCleanTempAvg());
            obj.getCalHotWaterRinseTempArr().add(cal.getCalHotWaterRinseTempAvg());
            obj.getCalRcZ12H2Arr().add(cal.getCalRcZ12H2());
            obj.getCalHeatH2Arr().add(cal.getCalHeatH2Avg());
            if (cal.getCalHeatFurPressureAvg() != null) {
                obj.getCalHeatFurPressureArr().add(cal.getCalHeatFurPressureAvg().multiply(BigDecimal.valueOf(1000)));
            } else {
                obj.getCalHeatFurPressureArr().add(null);
            }
            obj.getCalQuenchTempArr().add(cal.getCalQuenchTempAvg());
            obj.getCalQuenchCondArr().add(cal.getCalQuenchCondAvg());
        }

        return ResultData.ResultDataSuccess(obj);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public ResultData<String> transData(String beginTime) {
        beginTime = beginTime.replaceAll("-", "");
        //加载被检查PDO1630数据
        List<AnnealingBase> list = cal1630Mapper.select1630Base(beginTime);
        if (list.size() > 0) {
            List<String> entId1630List = new ArrayList<>();
            for (AnnealingBase item : list) {
                entId1630List.add(item.getEntid());
            }
            Map<String, TPdiDataL3Cal1630> map1630 = new HashMap<>();
            LambdaQueryWrapper<TPdiDataL3Cal1630> w1 = new LambdaQueryWrapper<>();
            w1.in(TPdiDataL3Cal1630::getEntid, entId1630List);
            List<TPdiDataL3Cal1630> pdiList = pdi1630Service.list(w1);
            for (TPdiDataL3Cal1630 item : pdiList) {
                map1630.put(item.getEntid(), item);
            }
            for (AnnealingBase item : list) {
                if (map1630.containsKey(item.getEntid())) {
                    TPdiDataL3Cal1630 pdi = map1630.get(item.getEntid());
                    item.setRoughAim(pdi.getRoughAim());
                    item.setSpmElongAim(pdi.getSpmElongAim());
                    item.setInMatWidth(pdi.getInMatWidth());
                    item.setInMatThick(pdi.getInMatThick());
                }
            }
        }

        List<AnnealingBase> list2 = cal2150Mapper.select2150Base(beginTime);
        if (list2.size() > 0) {
            List<String> entId2150List = new ArrayList<>();
            for (AnnealingBase item : list2) {
                entId2150List.add(item.getEntid());
            }
            Map<String, TPdiDataL3Cal2150> map2150 = new HashMap<>();
            LambdaQueryWrapper<TPdiDataL3Cal2150> w1 = new LambdaQueryWrapper<>();
            w1.in(TPdiDataL3Cal2150::getEntid, entId2150List);
            List<TPdiDataL3Cal2150> pdiList = pdi2150Service.list(w1);
            for (TPdiDataL3Cal2150 item : pdiList) {
                map2150.put(item.getEntid(), item);
            }
            for (AnnealingBase item : list2) {
                if (map2150.containsKey(item.getEntid())) {
                    TPdiDataL3Cal2150 pdi = map2150.get(item.getEntid());
                    item.setRoughAim(pdi.getRoughAim());
                    item.setSpmElongAim(pdi.getSpmElongAim());
                    item.setInMatWidth(pdi.getInMatWidth());
                    item.setInMatThick(pdi.getInMatThick());
                }
            }
        }

        list.addAll(list2);
        if (list.size() == 0) {
            return ResultData.ResultDataSuccess("success");
        }

        //从MongoDB中获取这些指标值
        String[] arr = new String[]{
                "cal_process_speed_avg", "cal_spm_ra_avg", "cal_heat_strip_temp_avg", "cal_sc_strip_temp_avg",
                "cal_rc_strip_temp_avg", "cal_oas3_strip_temp_avg", "cal_spm_elong_act_avg", "cal_alkali1_wash_cond_avg",
                "cal_alkali2_wash_cond_avg", "cal_alkali1_wash_temp_avg", "cal_alkali2_wash_temp_avg", "cal_elec_clean_cond_avg",
                "cal_elec_clean_temp_avg", "cal_hot_water_rinse_temp_avg", "cal_heat_h2_avg", "cal_heat_fur_pressure_avg",
                "cal_quench_temp_avg", "cal_quench_cond_avg", "cal_rc_z12_h2_avg"
        };

        //指标范围分类
        Map<String, List<TTechAnnealingParam>> paramMap = new HashMap<>();
        List<TTechAnnealingParam> paramList = paramService.list();
        for (TTechAnnealingParam p : paramList) {
            String comp = StringUtils.isEmpty(p.getCompany()) ? "" : p.getCompany();
            String key = p.getProNo() + "_" + p.getSurface() + "_" + comp;
            if (StringUtils.isNotEmpty(p.getBrand())) {
                key = p.getBrand();
            }
            if (paramMap.containsKey(key)) {
                paramMap.get(key).add(p);
            } else {
                List<TTechAnnealingParam> pList = new ArrayList<>();
                pList.add(p);
                paramMap.put(key, pList);
            }
        }

        List<CalProcessDatas> calList = new ArrayList<>();
        for (AnnealingBase item : list) {
            CalProcessDatas obj = new CalProcessDatas();
            //构建基本属性
            obj.setLineCode(item.getLineCode());
            obj.setEntid(item.getEntid());
            obj.setExtid(item.getExtid());
            obj.setStartime(item.getProdStartTime());
            obj.setEndtime(item.getProdEndTime());
            obj.setToc(item.getCreateTime());
            obj.setSteelgrade(item.getSteelgrade());
            obj.setInMatWidth(item.getInMatWidth());
            obj.setInMatThk(item.getInMatThick());
            obj.setRoughAim(item.getRoughAim());
            obj.setSpmElongAim(item.getSpmElongAim());
            obj.setSurfaceAccuClassCode(item.getSurfaceAccuClassCode());

            //从MongoDB中读取轧卷对应的指标
            Query query = new Query();
            query.addCriteria(Criteria.where("flag").is(1));
            for (int i = 0; i < arr.length; i++) {
                query.fields().include("trailValues." + arr[i]);
            }
            query.addCriteria(Criteria.where("extid").is(item.getExtid()));

            Map<String, Double> map;
            //从MongoDB中加载1630、2150数据
            if ("cal1630".equals(obj.getLineCode())) {
                JDataSavemong1630 mongoData = mongoTemplate.findOne(query, JDataSavemong1630.class);
                if (mongoData == null) {
                    map = new HashMap<>();
                    log.warn("卷号{}，获取MongoDB，{}产线数据失败", item.getExtid(), item.getLineCode());
                } else {
                    map = mongoData.getTrailValues();
                }
            } else {
                JDataSavemong2150 mongoData = mongoTemplate.findOne(query, JDataSavemong2150.class);
                if (mongoData == null) {
                    map = new HashMap<>();
                    log.warn("卷号{}，获取MongoDB，{}产线数据失败", item.getExtid(), item.getLineCode());
                } else {
                    map = mongoData.getTrailValues();
                }
            }

            //赋值MongoDB中的数据
            obj.setCalProcessSpeedAvg(readValue(map, arr[0]));
            obj.setCalSpmRaAvg(readValue(map, arr[1]));
            obj.setCalHeatStripTempAvg(readValue(map, arr[2]));
            obj.setCalScStripTempAvg(readValue(map, arr[3]));
            obj.setCalRcStripTempAvg(readValue(map, arr[4]));
            obj.setCalOas3StripTempAvg(readValue(map, arr[5]));
            obj.setCalSpmElongActAvg(readValue(map, arr[6]));
            obj.setCalAlkali1WashCondAvg(readValue(map, arr[7]));
            obj.setCalAlkali2WashCondAvg(readValue(map, arr[8]));
            obj.setCalAlkali1WashTempAvg(readValue(map, arr[9]));
            obj.setCalAlkali2WashTempAvg(readValue(map, arr[10]));
            obj.setCalElecCleanCondAvg(readValue(map, arr[11]));
            obj.setCalElecCleanTempAvg(readValue(map, arr[12]));
            obj.setCalHotWaterRinseTempAvg(readValue(map, arr[13]));
            obj.setCalHeatH2Avg(readValue(map, arr[14]));
            obj.setCalHeatFurPressureAvg(readValue(map, arr[15]));
            obj.setCalQuenchTempAvg(readValue(map, arr[16]));
            obj.setCalQuenchCondAvg(readValue(map, arr[17]));
            obj.setCalRcZ12H2(readValue(map, arr[18]));

            paramService.checkParam(paramMap, obj);

            calList.add(obj);
        }
        saveOrUpdateBatch(calList);
        return ResultData.ResultDataSuccess("success");
    }

    @Override
    public List<TechListDtoRes> loadCalProcessData(TechChartDtoReq tc) {
        List<TechListDtoRes> list = new ArrayList<>();

        LambdaQueryWrapper<CalProcessDatas> w = buildCalWrapper(tc);
        //查询出口卷号
        w.select(CalProcessDatas::getExtid);
        List<CalProcessDatas> dbList = list(w);
        for (int i = 0; i < dbList.size(); i++) {
            CalProcessDatas obj = dbList.get(i);
            TechListDtoRes res = new TechListDtoRes();
            res.setSeqno(i + 1);
            res.setVolumeNo(obj.getExtid());
            list.add(res);
        }
        return list;
    }

    @Override
    public ResultData<String> rollInfo(TechChartDtoReq tc) {
        Date d = new Date();
        String d1 = DateUtil.getBeforeHourStart(d);
        String d2 = DateUtil.getDateToString(d, "yyyyMMddHH");
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        int h = cal.get(Calendar.HOUR_OF_DAY);

        LambdaQueryWrapper<CalProcessDatas> wrapper = new LambdaQueryWrapper();
        wrapper.select(CalProcessDatas::getCalProcessSpeedJudge,
                        CalProcessDatas::getCalSpmRaJudge,
                        CalProcessDatas::getCalHeatStripTempJudge,
                        CalProcessDatas::getCalScStripTempJudge,
                        CalProcessDatas::getCalRcStripTempJudge,
                        CalProcessDatas::getCalOas3StripTempJudge,
                        CalProcessDatas::getCalSpmElongActJudge,
                        CalProcessDatas::getCalAlkali1WashCondJudge,
                        CalProcessDatas::getCalAlkali2WashCondJudge,
                        CalProcessDatas::getCalAlkali1WashTempJudge,
                        CalProcessDatas::getCalAlkali2WashTempJudge,
                        CalProcessDatas::getCalElecCleanCondJudge,
                        CalProcessDatas::getCalElecCleanTempJudge,
                        CalProcessDatas::getCalHotWaterRinseTempJudge,
                        CalProcessDatas::getCalRcZ12H2Judge,
                        CalProcessDatas::getCalHeatH2Judge,
                        CalProcessDatas::getCalHeatFurPressureJudge,
                        CalProcessDatas::getCalQuenchTempJudge,
                        CalProcessDatas::getCalQuenchCondJudge
                ).ge(CalProcessDatas::getEndtime, d1).le(CalProcessDatas::getEndtime, d2)
                .eq(CalProcessDatas::getLineCode, tc.getProdLine());
        List<CalProcessDatas> dbList = list(wrapper);
        String[] titleArr = new String[]{
                "工艺段速度均值", "粗糙度检测仪均值", "加热段带温均值", "缓冷段带温均值",
                "快冷段带温均值", "时效3段带温均值", "平整延伸率实际值均值", "#1碱浸刷洗槽循环槽碱液电导率平均值",
                "#2碱浸刷洗槽循环槽碱液电导率平均值", "#1碱浸刷洗槽循环槽碱液温度平均值", "#2碱浸刷洗槽循环槽碱液温度平均值", "电解清洗循环槽碱液电导率平均值",
                "电解清洗循环槽碱液温度平均值", "热水漂洗循环槽温度", "快冷Z1-2段氢含量", "Htg1氢含量",
                "Htg1炉压", "水淬槽水温", "水淬槽电导率"};
        int[] countArr = new int[titleArr.length];
        for (CalProcessDatas data : dbList) {
            if (data.getCalProcessSpeedJudge() != null && data.getCalProcessSpeedJudge() == 1) countArr[0]++;
            if (data.getCalSpmRaJudge() != null && data.getCalSpmRaJudge() == 1) countArr[1]++;
            if (data.getCalHeatStripTempJudge() != null && data.getCalHeatStripTempJudge() == 1) countArr[2]++;
            if (data.getCalScStripTempJudge() != null && data.getCalScStripTempJudge() == 1) countArr[3]++;
            if (data.getCalRcStripTempJudge() != null && data.getCalRcStripTempJudge() == 1) countArr[4]++;

            if (data.getCalOas3StripTempJudge() != null && data.getCalOas3StripTempJudge() == 1) countArr[5]++;
            if (data.getCalSpmElongActJudge() != null && data.getCalSpmElongActJudge() == 1) countArr[6]++;
            if (data.getCalAlkali1WashCondJudge() != null && data.getCalAlkali1WashCondJudge() == 1) countArr[7]++;
            if (data.getCalAlkali2WashCondJudge() != null && data.getCalAlkali2WashCondJudge() == 1) countArr[8]++;
            if (data.getCalAlkali1WashTempJudge() != null && data.getCalAlkali1WashTempJudge() == 1) countArr[9]++;

            if (data.getCalAlkali2WashTempJudge() != null && data.getCalAlkali2WashTempJudge() == 1) countArr[10]++;
            if (data.getCalElecCleanCondJudge() != null && data.getCalElecCleanCondJudge() == 1) countArr[11]++;
            if (data.getCalElecCleanTempJudge() != null && data.getCalElecCleanTempJudge() == 1) countArr[12]++;
            if (data.getCalHotWaterRinseTempJudge() != null && data.getCalHotWaterRinseTempJudge() == 1) countArr[13]++;
            if (data.getCalRcZ12H2Judge() != null && data.getCalRcZ12H2Judge() == 1) countArr[14]++;

            if (data.getCalHeatH2Judge() != null && data.getCalHeatH2Judge() == 1) countArr[15]++;
            if (data.getCalHeatFurPressureJudge() != null && data.getCalHeatFurPressureJudge() == 1) countArr[16]++;
            if (data.getCalQuenchTempJudge() != null && data.getCalQuenchTempJudge() == 1) countArr[17]++;
            if (data.getCalQuenchCondJudge() != null && data.getCalQuenchCondJudge() == 1) countArr[18]++;
        }
        List<RollInfo> list = new ArrayList<>();
        for (int i = 0; i < titleArr.length; i++) {
            list.add(new RollInfo(titleArr[i], countArr[i]));
        }
        Collections.sort(list);

        String res = "";
        StringBuffer sbf = new StringBuffer();
        sbf.append(h - 1).append(":00-").append(h).append(":00").append(" 总生产卷数:" + dbList.size());
        sbf.append(list.size() == 0 ? "。" : "，");
        for (int i = 0; i < list.size(); i++) {
            RollInfo ri = list.get(i);
            if (ri.getCount() == 0) {
                res = sbf.substring(0, sbf.length() - 1) + "。";
                break;
            }
            sbf.append(ri.getTitle()).append("超限:").append(ri.getCount());
            sbf.append(i < list.size() - 1 ? "，" : "。");
        }
        return ResultData.ResultDataSuccess(res.length() > 0 ? res : sbf.toString());
    }

    public LambdaQueryWrapper<CalProcessDatas> buildCalWrapper(TechChartDtoReq tc) {
        Date d1 = DateUtil.getStringToDate("yyyy-MM-dd HH:mm:ss", tc.getStartDate());
        Date d2 = DateUtil.getStringToDate("yyyy-MM-dd HH:mm:ss", tc.getEndDate());
        LambdaQueryWrapper<CalProcessDatas> w = new LambdaQueryWrapper<>();
        //产线
        if (StringUtils.isNotEmpty(tc.getProdLine())) {
            w.eq(CalProcessDatas::getLineCode, tc.getProdLine());
        }
        //开始时间
        if (StringUtils.isNotEmpty(tc.getStartDate())) {
            w.ge(CalProcessDatas::getStartime, DateUtil.getDateToString(d1, "yyyyMMddHHmmss"));
        } else {
            //最近1天
            Calendar cal = Calendar.getInstance();
            cal.setTime(d1);
            cal.add(Calendar.DAY_OF_MONTH, -1);
            w.ge(CalProcessDatas::getStartime, DateUtil.getDateToString(cal.getTime(), "yyyyMMddHHmmss"));
        }
        //结束时间
        if (StringUtils.isNotEmpty(tc.getEndDate())) {
            w.le(CalProcessDatas::getEndtime, DateUtil.getDateToString(d2, "yyyyMMddHHmmss"));
        }
        //钢种
        if (StringUtils.isNotEmpty(tc.getSteelGrade())) {
            w.eq(CalProcessDatas::getSteelgrade, tc.getSteelGrade());
        }
        //入口宽度
        if (tc.getEntWidthStart() != null) {
            w.ge(CalProcessDatas::getInMatWidth, tc.getEntWidthStart());
        }
        if (tc.getEntWidthEnd() != null) {
            w.le(CalProcessDatas::getInMatWidth, tc.getEntWidthEnd());
        }
        //入口厚度
        if (tc.getEntThickStart() != null) {
            w.ge(CalProcessDatas::getInMatThk, tc.getEntThickStart());
        }
        if (tc.getEntThickEnd() != null) {
            w.le(CalProcessDatas::getInMatThk, tc.getEntThickEnd());
        }
        w.orderByAsc(CalProcessDatas::getEndtime);
        return w;
    }

    private BigDecimal readValue(Map<String, Double> map, String key) {
        if (map.get(key) != null) {
            return BigDecimal.valueOf(map.get(key));
        }
        log.warn("{} 变量数据不存在", key);
        return null;
    }
}
